//
//  YFDongtaiCell.m
//  project
//
//  Created by yefei on 2019/4/15.
//  Copyright © 2019 健健. All rights reserved.
//

#import "YFDongtaiCell.h"
#import "YFDongtaiModel.h"

@interface YFDongtaiCell ()

@property (weak, nonatomic) IBOutlet UIView *containerView;
@property (weak, nonatomic) IBOutlet UIButton *editButton;
@property (weak, nonatomic) IBOutlet UIButton *likeButton;
@property (weak, nonatomic) IBOutlet UIImageView *dongtaiImageView;
@property (weak, nonatomic) IBOutlet UIButton *playButton;



@end


@implementation YFDongtaiCell

- (void)setModel:(YFDongtaiRecordModel *)model {
    _model = model;
    [self.dongtaiImageView sd_setImageWithURL:[NSURL URLWithString:model.previewImageName] placeholderImage:nil];
    [self.likeButton setTitle:model.praiseAmount forState:(UIControlStateNormal)];
    self.playButton.hidden = model.isImage;
}

- (void)setIsEditting:(BOOL)isEditting {
    _isEditting = isEditting;
    self.editButton.hidden = !isEditting;
    [self.editButton setImage:[UIImage imageNamed:@"icon_dongtai_manage_unselected"] forState:(UIControlStateNormal)];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    [self setupViews];
}

- (void)setupViews {
    self.isEditting = NO;
    [self.containerView rounded:(UIRectCornerAllCorners) radius:5];
}

- (IBAction)editButtonClicked:(UIButton *)sender {
    sender.selected = !sender.selected;
    UIImage *image = [UIImage imageNamed: sender.selected ? @"icon_dongtai_manage_selected" : @"icon_dongtai_manage_unselected"];
    [sender setImage:image forState:(UIControlStateNormal)];
    
    if (_editDeleteAction) _editDeleteAction(sender.selected, self.model.albumId);
}




@end
